package com.ruoyi.quartz.utils;

import org.apache.http.HttpStatus;

import java.util.HashMap;

public class Result extends HashMap<String, Object> {
    private static final long serialVersionUID = 1L;

    public Result() {
        put("code", "1");
        put("message", "成功");
    }

    public static Result error() {
        return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, "未知异常，请联系管理员");
    }

    public static Result error(String msg) {
        return error(HttpStatus.SC_INTERNAL_SERVER_ERROR, msg);
    }

    public static Result error(int code, String msg) {
        Result r = new Result();
        r.put("code", code);
        r.put("message", msg);
        return r;
    }

    public static Result ok(String msg) {
        Result r = new Result();
        r.put("message", msg);
        return r;
    }

    public static Result ok() {
        return new Result();
    }

    public Result put(String key, Object value) {
        super.put(key, value);
        return this;
    }

    public static Result r() {
        Result r = new Result();
        r.clear();
        return r;
    }

    public static Result ok(Object object) {
        Result r = new Result();
        r.put("data_result", object);
        return r;
    }
}
